package com.example.graduationdesign.service.Impl;

import com.example.graduationdesign.mapper.ConsumerMapper;
import com.example.graduationdesign.pojo.dao.*;
import com.example.graduationdesign.pojo.dto.*;
import com.example.graduationdesign.pojo.vo.*;
import com.example.graduationdesign.service.ConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConsumerServiceImpl implements ConsumerService {
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;
    @Autowired
    private ConsumerMapper consumerMapper;
    @Override
    public List<WordDao> wordinfo(Integer userStage) {
        // 1. 在Redis中取出当前用户的Id，用于找到当前教练所教的学员的基本信息
        // 1.1. 获取 token,从而得到当前登录用户的基本信息
//        String token = CommonUtil.getCurrentUserToken();
//        UserVo userVo = JSONObject.parseObject(String.valueOf(redisTemplate.opsForValue().get(Constant.CLIENT_TOKEN + token)), UserVo.class);

//        System.out.println(userVo);
        List<WordDao> wordDaos;
        wordDaos = consumerMapper.queryWordByWordStage(userStage);
        System.out.println("--------------------------------");
        System.out.println(1);
        return wordDaos;
//        return null;
    }

    @Override
    public Void UpadateStudyStatus(UserStatusStudyDao userStatusStudyDao) {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
        userStatusStudyDao.setCreateTime(now);
        System.out.println(userStatusStudyDao);
        System.out.println(consumerMapper.IsExistThisStudyRecord(userStatusStudyDao));
        if ((consumerMapper.IsExistThisStudyRecord(userStatusStudyDao))== null){
            consumerMapper.AddUserStatusStudy(userStatusStudyDao);
        }
        else if((consumerMapper.IsExistThisStudyRecord(userStatusStudyDao)).getStudyrecordConsumerId().equals(userStatusStudyDao.getConsumerId())
        && (consumerMapper.IsExistThisStudyRecord(userStatusStudyDao).getStudyrecordCode().equals(userStatusStudyDao.getCode()))){
            consumerMapper.UpdateUserStatusStudy(userStatusStudyDao);
        }

        return null;
    }

    @Override
    public UserStatusStudyDao GetStatus(StudyRecordDto studyRecordDto) {
        UserStatusStudyDao userStatusStudyDao = consumerMapper.QueryDataStudyRecord(studyRecordDto);
        if(userStatusStudyDao ==null){
            UserStatusStudyDao userStatusStudyDao1 = new UserStatusStudyDao();
            userStatusStudyDao1.setConsumerId(studyRecordDto.getStudyrecordConsumerId());
            userStatusStudyDao1.setCode(studyRecordDto.getStudyrecordCode());
            userStatusStudyDao1.setIsStudyed(false);
            userStatusStudyDao1.setIsFamilarized(false);
            userStatusStudyDao1.setIsLike(false);
            userStatusStudyDao1.setIsFavorite(false);
            userStatusStudyDao1.setCreateTime(null);
            return  userStatusStudyDao1;
        }
        return userStatusStudyDao;
    }

    @Override
    public Void isLikeOrFavorite(LikeOrFavoriteDao likeOrFavoriteDao) {
        if(likeOrFavoriteDao.getIsFavorite() == null ){
            consumerMapper.UpdateUserStatusLike(likeOrFavoriteDao);
        }
        if(likeOrFavoriteDao.getIsLike() == null){
            consumerMapper.UpdateUserStatusFavorite(likeOrFavoriteDao);
        }
        return null;
    }

    /**
     * 用于用户获取其打卡的题目
     * @param ConsumerStage
     * @param ConsumerId
     * @return
     */
    @Override
    public List<QuestionCheckDao> GetCheckQuestion(Integer ConsumerStage, Long ConsumerId) {
        List<QuestionCheckDao> questionCheckDao = consumerMapper.GetCheckQuestion(ConsumerStage,ConsumerId);
        return questionCheckDao;
    }

    @Override
    public Integer WriteCheckRecord(QuestionCheckDto questionCheckDto) {
        List<QuestionCheckDao> questionCheckDaos = questionCheckDto.getCurrentQuestion();
        System.out.println("-------------------------11111111111111--------------");
        System.out.println(questionCheckDaos);
        String activeType = questionCheckDto.getActivityType();
        Long consumerId = Long.parseLong(questionCheckDto.getConsumerId());
        if(activeType.equals("translation-en-to-zh")){
            for (QuestionCheckDao questionCheckDao: questionCheckDaos) {
                // 循环体
                if(questionCheckDao.getUserAnswer().equals(questionCheckDao.getZn())){
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(1);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(2);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getEn());
                    checkRecordDao.setRightAnswer(questionCheckDao.getZn());
                    checkRecordDao.setCheckrecordIsMastered(1);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
                else {
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(0);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(2);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getEn());
                    checkRecordDao.setRightAnswer(questionCheckDao.getZn());
                    checkRecordDao.setCheckrecordIsMastered(0);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
            }
        } else if (activeType.equals("translation-zh-to-en")) {
            for (QuestionCheckDao questionCheckDao: questionCheckDaos){
                System.out.println(questionCheckDao);
                // 循环体
                if(questionCheckDao.getUserAnswer().equals(questionCheckDao.getEn())){
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(1);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(1);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getZn());
                    checkRecordDao.setRightAnswer(questionCheckDao.getEn());
                    checkRecordDao.setCheckrecordIsMastered(1);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
                else {
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(0);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(1);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getZn());
                    checkRecordDao.setRightAnswer(questionCheckDao.getEn());
                    checkRecordDao.setCheckrecordIsMastered(0);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
            }
        }
        else {
            for (QuestionCheckDao questionCheckDao: questionCheckDaos){
                // 循环体
                if(questionCheckDao.getUserAnswer().equals(questionCheckDao.getWord())){
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(1);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(0);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getDefinition());
                    checkRecordDao.setRightAnswer(questionCheckDao.getWord());
                    checkRecordDao.setCheckrecordIsMastered(1);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
                else {
                    // 获取当前时间
                    LocalDateTime now = LocalDateTime.now();
                    CheckRecordDao checkRecordDao = new CheckRecordDao();
                    checkRecordDao.setCheckrecordIsTrue(0);
                    checkRecordDao.setCheckrecordConsumerId(consumerId);
                    checkRecordDao.setCheckrecordCode(questionCheckDao.getCode());
                    checkRecordDao.setCheckrecordTime(now);
                    checkRecordDao.setCheckrecordStyle(0);
                    checkRecordDao.setUserAnswer(questionCheckDao.getUserAnswer());
                    checkRecordDao.setUserQuestion(questionCheckDao.getDefinition());
                    checkRecordDao.setRightAnswer(questionCheckDao.getWord());
                    checkRecordDao.setCheckrecordIsMastered(0);
                    consumerMapper.InsertCheckRecord(checkRecordDao);
                }
            }
        }

        return null;
    }


    /**
     * 用于获取用户今日是否打卡的Service层实现
     * @param consumerId
     * @return
     */
    @Override
    public Integer GetIsChecked(Long consumerId) {
        System.out.println(consumerId);
        Integer count = consumerMapper.GetIsChecked(consumerId);
        System.out.println(count);
        if(count == 5){
            return 1;
        }
        else {
            return 0;
        }

    }

    /**
     * 用于获取用户的打卡记录的Service层的实现层
     * @param consumerId
     * @return
     */
    @Override
    public List<CheckRecordDao> GetCheckRecords(Long consumerId) {
        List<CheckRecordDao> checkRecordDaos = consumerMapper.GetCheckRecords(consumerId);
        return checkRecordDaos;
    }


    /**
     * 用于删除用户某个日期的所有打卡记录
     * @param checkRecordDao
     * @return
     */
    @Override
    public Void DeleteCheckRecords(CheckRecordDao checkRecordDao) {
        consumerMapper.DeleteCheckRecord(checkRecordDao);

        return null;
    }


    /**
     * 用于获取用户测试的题目
     * @param wordStage
     * @return
     */
    @Override
    public List<WordDao> GetTestQuestion(Integer wordStage) {
        List<WordDao> wordDaos = consumerMapper.GetTestWord(wordStage);
        return wordDaos;
    }

    /**
     * 用于获取用户所需要学习的单词数量
     * @param userStage
     * @return
     */
    @Override
    public Integer GetWordNumber(Integer userStage) {
        return (consumerMapper.queryWordByWordStage(userStage)).size();
    }


    /**
     * 用于获取用户在某个阶段已经熟悉的单词总数
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public Integer GetFamilarNumber(Long userId, Integer userStage) {
        Integer count = consumerMapper.GetFamilarNumber(userId,userStage);
        return count;
    }

    /**
     * 获取用户点赞的单词个数
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public Integer GetLikeNumber(Long userId, Integer userStage) {
        Integer count = consumerMapper.GetLikeNumber(userId,userStage);
        return count;
    }


    /**
     * 获取用户收藏的单词个数
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public Integer GetFavoriteNumber(Long userId, Integer userStage) {
        Integer count = consumerMapper.GetFavoriteNumber(userId,userStage);
        return count;
    }



    @Override
    public Void SetArticleReadNumber(Long articleId) {
        consumerMapper.SetArticleReadNumber(articleId);
        return null;
    }

    /**
     * 用于获取用户需要默写的英语单词
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public List<WordDao> GetReciteWord(Long userId, Integer userStage) {
        List<WordDao> wordDaos = consumerMapper.GetReciteWord(userId,userStage);
        return wordDaos;
    }

    /**
     * 用于用户获取积分的大小
     * @param userId
     * @return
     */
    @Override
    public Long GetScore(Long userId) {
        Long score = consumerMapper.GetScore(userId);
        return score;
    }

    /**
     * 用于获取用户的读书笔记内容
     * @param userId
     * @return
     */
    @Override
    public List<NoteBookDao> GetNoteBook(Long userId) {
        List<NoteBookDao> noteBookDaos = consumerMapper.GetNoteBook(userId);
        return noteBookDaos;
    }


    /**
     * 用于实现用户增加读书笔记的实现层
     * @param userId
     * @param title
     * @param content
     * @return
     */
    public Void AddNoteBook(Long userId,String title,String content){

        consumerMapper.AddNoteBook(userId,title,content);
        return null;
    }


    /**
     * 用于实现用户更新笔记的实现层
     * @param userId
     * @param code
     * @param content
     * @param title
     * @return
     */
    public Void UpdateNoteBook(Long userId, Long code, String content, String title){
        consumerMapper.UpdateNoteBook(userId,code,content,title);
        return null;
    }

    /**
     *
     * @param noteCode
     * @return
     */
    public Void DeleteNoteBook(Long noteCode){
        consumerMapper.DeleteNoteBook(noteCode);
        System.out.println("213"+noteCode);
        return null;
    }

    /**
     * 用于获取用户的排名
     * @param userId
     * @param userStage
     * @return
     */
    public Long GetRank(Long userId, Integer userStage){
        List<RankVo> rank = consumerMapper.GetRank(userStage);
        for(RankVo rankVo:rank){
            if(rankVo.getConsumerId().equals(userId)){
                Long number = rankVo.getUserRank();
                return number;
            }
        }
        return null;
    }


    /**
     * 实现与数据库中的wordlist表相连接
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public List<WordPersonalVo> GetAllWords(Long userId, Integer userStage) {
        List<WordPersonalVo> wordDaos = consumerMapper.GetAllWords(userId,userStage);
        return wordDaos;
    }

//    /**
//     * 实现获取用户收藏的单词数据
//     * @param userId
//     * @param userStage
//     * @return
//     */
//    @Override
//    public List<WordDao> GetFavoriteWords(Long userId, Integer userStage) {
//        List<WordDao> wordDaos = consumerMapper.GetFavoriteWords(userId,userStage);
//        return wordDaos;
//    }
//
//
//    /**
//     * 实现获取用户点赞的单词数据
//     * @param userId
//     * @param userStage
//     * @return
//     */
//    @Override
//    public List<WordDao> GetLikedWords(Long userId, Integer userStage) {
//        List<WordDao> wordDaos = consumerMapper.GetLikedWords(userId,userStage);
//        return wordDaos;
//
//    }


    /**
     * 用于获取轮播图数据
     * @return
     */
    @Override
    public List<BannersDto> GetBanners() {
        List<BannersDto> bannersDtos = consumerMapper.GetBanners();
        return bannersDtos;
    }

    /**
     * 用于获取用户在某个阶段的积分排名
     * @param stage
     * @return
     */
    @Override
    public List<ConsumerScoreDto> GetConsumerScoreRank(Integer stage) {
        List<ConsumerScoreDto> consumerScoreDtos = consumerMapper.GetConsumerScoreRank(stage);
        return consumerScoreDtos;
    }


    /**
     * 用于获取某个阶段用户的学习进度排名
     * @param stage
     * @return
     */
    @Override
    public List<ProgressRankDto> GetProgressRank(Integer stage) {
        System.out.println(stage);

        List<ProgressRankDto> progressRankDtos = consumerMapper.GetProgressRank(stage);
        return progressRankDtos;
    }


    /**
     * 用于获取用户在某一个阶段的学习进度数据
     * @param userId
     * @param stage
     * @return
     */
    @Override
    public MyStudyProgressDto getPersonalProgress(Long userId, Integer stage) {
        MyStudyProgressDto progress = consumerMapper.GetData(userId, stage);
        List<WeeklyDataDao> weeklyData = consumerMapper.getWeeklyStudyData(userId,stage);
        progress.setWeeklyData(weeklyData);
        return progress;
    }


    /**
     * 用于实时更新用户闯关数据放地实现层
     * @param userId
     * @param newLevel
     * @return
     */
    @Override
    public Void SetUserLevel(Long userId, Integer newLevel) {
        consumerMapper.SetUserLevel(userId,newLevel);
        return null;
    }


    /**
     * 用于获取用户在某阶段的所需要学习的单词数据
     * @param userId
     * @param userStage
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<WordDao> GetWord(Long userId,Integer userStage, Integer pageNum, Integer pageSize) {
       List<WordDao> wordDaos = consumerMapper.GetWord(userStage,(pageNum - 1) * pageSize, pageSize);
        return new PageInfo<>(consumerMapper.GetAllWords(userId,userStage).size(), wordDaos);
    }

    /**
     * 测试数据插入数据库的实现层
     * @param submitTestDto
     * @return
     */
    @Override
    public Long SubmitTest(SubmitTestDto submitTestDto) {
        System.out.println(submitTestDto);
        List<TestDataDto> testDataDtos = submitTestDto.getTestDataDtos();
        Long userId = submitTestDto.getUserId();
        Integer totalScore = 0;
        for(TestDataDto testDataDto : testDataDtos){
            consumerMapper.SubmitTest(userId,testDataDto);
            if(testDataDto.getIsCorrect()){
                totalScore+=2* consumerMapper.GetWordDifficulty(testDataDto.getWordCode());
            }
        }
        consumerMapper.SetConsumerScore(userId,totalScore);
        return consumerMapper.GetScore(userId);
    }

    /**
     * 主要用于获取某用户在某学习阶段的打卡错误记录
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public List<CheckMistakesVo> GetCheckMistakes(Long userId, Integer userStage) {


        return consumerMapper.GetCheckMistakes(userId,userStage);
    }

    /**
     * 主要用于获取某用户在某阶段的测试错误记录
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public List<TestMistakesVo> GetTestMistakes(Long userId, Integer userStage) {
        return consumerMapper.GetTestMistakes(userId,userStage);
    }


    /**
     * 用于获取某个单词的详细信息
     * @param wordCode
     * @return
     */
    @Override
    public WordDao GetWordDetail(Long wordCode) {

        return consumerMapper.GetWordDetail(wordCode);
    }

    /**
     * 用于获取打卡情况中已经掌握的单词数量
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public Long GetCheckMasterCount(Long userId, Integer userStage) {
        return consumerMapper.GetCheckMasterCount(userId,userStage);
    }


    /**
     * 用于获取测试情况中已经掌握的单词数量
     * @param userId
     * @param userStage
     * @return
     */
    @Override
    public Long GetTestMasterCount(Long userId, Integer userStage) {
        return consumerMapper.GetTestMasterCount(userId,userStage);
    }

    /**
     * 用于帮助用户对打卡错题集的更新
     * @param userId
     * @param wordCode
     * @param time
     * @return
     */
    @Override
    public Void UpdateCheckMistakesMastered(Long userId, Long wordCode, String time) {
        System.out.println("2222"+userId+wordCode+time);

        consumerMapper.UpdateCheckMistakesMastered(userId,wordCode,time);
        return null;
    }

    /**
     * 用于帮助用户对测试错题集的更新
     * @param userId
     * @param wordCode
     * @param time
     * @return
     */
    @Override
    public Void UpdateTestMistakesMastered(Long userId, Long wordCode, String time) {
        System.out.println("11111111111"+userId+wordCode+time);
        consumerMapper.UpdateTestMistakesMastered(userId,wordCode,time);
        return null;
    }

    // 获取默写章节列表
    public List<Map<String, Object>> getReciteChapters(Long userId, Integer userStage) {
        // 获取该阶段的总单词数
        int totalWords = consumerMapper.CountByStage(userStage);

        // 计算章节数 (每20个单词为一章)
        int chapterCount = (int) Math.ceil((double) totalWords / 20);

        List<Map<String, Object>> chapters = new ArrayList<>();
        for (int i = 0; i < chapterCount; i++) {
            Map<String, Object> chapter = new HashMap<>();
            chapter.put("chapterIndex", i);
            chapter.put("wordCount", i == chapterCount - 1 ? totalWords % 20 : 20);
            chapters.add(chapter);
        }

        return chapters;
    }


    // 获取指定章节的单词
    public List<WordDao> getReciteWords(Long userId, Integer userStage, Integer chapterIndex) {
        // 计算分页参数
        int offset = chapterIndex * 20;
        int limit = 20;

        // 查询该章节的单词
        return consumerMapper.selectByStageWithLimit(userStage, offset, limit);
    }


    /**
     * 保存章节记录
     * @param reciteRecordDto
     * @return
     */
    @Override
    public Long saveReciteRecord(ReciteRecordDto reciteRecordDto) {
        // 保存章节记录
        ReciteChapterRecordDao chapterRecord = new ReciteChapterRecordDao();
        chapterRecord.setUserId(reciteRecordDto.getUserId());
        chapterRecord.setChapterIndex(reciteRecordDto.getChapterIndex());
        chapterRecord.setTotalWords(reciteRecordDto.getTotalWords());
        chapterRecord.setCorrectCount(reciteRecordDto.getCorrectCount());
        chapterRecord.setWrongCount(reciteRecordDto.getWrongCount());
        chapterRecord.setAccuracy(reciteRecordDto.getAccuracy());
        chapterRecord.setStartTime(reciteRecordDto.getStartTime());
        chapterRecord.setEndTime(reciteRecordDto.getEndTime());
        chapterRecord.setDuration(reciteRecordDto.getDuration());
        chapterRecord.setStage(reciteRecordDto.getStage());

        System.out.println(1);
        consumerMapper.InsertWriteRecord(chapterRecord);
        Long recordId = consumerMapper.GetPrimaryKey(chapterRecord.getUserId(),chapterRecord.getChapterIndex(),chapterRecord.getStage());//实现数据往数据库中插入的操作
        System.out.println(2);
        System.out.println(reciteRecordDto.getDetails());
        // 保存详情记录
        for (ReciteDetailDto detail : reciteRecordDto.getDetails()) {
            System.out.println(detail);
            ReciteDetailDao reciteDetail = new ReciteDetailDao();
            reciteDetail.setRecordId(recordId);
            reciteDetail.setWordId(detail.getWordId());
            reciteDetail.setWord(detail.getWord());
            reciteDetail.setInterpretation(detail.getInterpretation());
            reciteDetail.setUserAnswer(detail.getUserAnswer());
            reciteDetail.setIsCorrect(detail.getIsCorrect());

           consumerMapper.InsertReciteDetail(reciteDetail);
        }

        return recordId;
    }

    /**
     * 用于评判用户在当前阶段的章节是否已经完成默写
     * @param userId
     * @param userStage
     * @param chapterIndex
     * @return
     */
    @Override
    public IsCompleteVo checkChapterCompletion(Long userId, Integer userStage, Integer chapterIndex) {

        IsCompleteVo isCompleteVo = new IsCompleteVo();
        Long recordId = consumerMapper.GetPrimaryKey(userId,chapterIndex,userStage);
        System.out.println(recordId+"232131313");
        if(recordId!=null){

            ReciteChapterRecordDao reciteChapterRecordDao = consumerMapper.GetReciteChapterRecord(recordId);
            isCompleteVo.setHasCompleted(true);
            isCompleteVo.setAccuracy(reciteChapterRecordDao.getAccuracy());
            isCompleteVo.setCorrectCount(reciteChapterRecordDao.getCorrectCount());
            isCompleteVo.setRecordId(recordId);
            isCompleteVo.setWrongCount(reciteChapterRecordDao.getWrongCount());
            return isCompleteVo;
        }
        return isCompleteVo;
    }


    /**
     * 获取默写报告
     * @param userId
     * @param recordId
     * @return
     */
    @Override
    public WriteReportVo getReciteReport(Long userId, Long recordId) {
        return consumerMapper.getReciteReport(userId,recordId);
    }

    // 获取默写详情
    @Override
    public List<WriteReportDetailVo> getReciteDetails(Long recordId) {
        return consumerMapper.getReciteDetails(recordId);
    }


    //用于实现删除用户在默写时的数据
    @Override
    public Void DeleteData(Long recordId) {
        consumerMapper.DeleteReciteChapterRecordData(recordId);
        consumerMapper.DeleteReciteDetailData(recordId);
        return null;
    }

    /**
     * 用于实现用户利用积分兑换VIP的操作
     * @param consumerId
     * @return
     */
    @Override
    public Void ExchangeVip(Long consumerId) {
        consumerMapper.ExchangeVip(consumerId);
        return null;
    }
}
